package com.atguigu.day16.work;

import java.io.InterruptedIOException;

public class Work1 {
    public static void main(String[] args) throws InterruptedIOException {
        int[] a = new int[1000];
        for (int i = 0; i < a.length; i++) {
            a[i] = i;
        }
        int i = 0;
        int count = 0;
        int delNum = 0;
        while (true) {
            if (a[i] != -1) {
                count++;
            }
            if (count == 3) {
                a[i] = -1;
                count = 0;
                delNum++;
            }
            if (delNum == a.length - 1) {
                break;
            }
            if (++i == a.length) {
                i = 0;
            }
        }
        for (int j = 0; j < a.length; j++) {
            if (a[j] != -1) {
                System.out.println("最后一个被删掉的数是:a[j]=" + a[j] + ",它的下标:" + j);
            }
        }
        System.out.println(delNum);
        System.out.println(a.length-1);
    }
}
